<?php

namespace ms\modules\log\controllers;

use Yii;
use common\models\ModelLog;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use common\models\CompareLog;

/**
 * ModelLogController implements the CRUD actions for ModelLog model.
 */
class CompareLogController extends Controller
{   
    public function actionIndex() {
    	$searchModel = new CompareLog();
    	!isset($_GET['sort']) && $_GET['sort'] = '-log_time';
    	$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
    	
    	return $this->render('index', [
    		'searchModel' => $searchModel,
    		'dataProvider' => $dataProvider,
    	]);    	
    }
    
    public function actionClear() {
    	CompareLog::deleteAll();
    	return $this->redirect(['index']);
    }

    /**
     * Displays a single ModelLog model.
     * @param integer $_id
     * @return mixed
     */
    public function actionView($id)
    {
        return $this->render('view', [
            'model' => $this->findModel($id),
        ]);
    }

   
    /**
     * Finds the ModelLog model based on its primary key value.
     * If the model is not found, a 404 HTTP exception will be thrown.
     * @param integer $_id
     * @return ModelLog the loaded model
     * @throws NotFoundHttpException if the model cannot be found
     */
    protected function findModel($id)
    {
        if (($model = CompareLog::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
}
